<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 定义数组
        var os_arr = ['linux', 'redhat', 'centos', 'ubuntu']
        console.log(os_arr)
        // 数组长度
        console.log(os_arr.length)
        // 清空数组
        // os_arr.length = 0
        // console.log(os_arr.length)
        // console.log(os_arr)
        // 访问数组元素  下标  从0开始
        console.log(os_arr[2])
        // 遍历数组
        for (var i = 0; i < os_arr.length; i++) {
            console.log(os_arr[i])
        }
        // 通过下边更新数组元素的值 或者添加元素
        os_arr[2] = 'CentOS'
        console.log(os_arr)
        os_arr[4] = 'win10'
        console.log(os_arr)
        // 数组排序
        var num_arr = [1,2,4,6,7,8,3,134,5,67]
        console.log(num_arr.sort())
        os_arr.push('win7')
        console.log(os_arr)
    </script>
</body>

</html>